package com.ruoyi.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.system.domain.CsOrnamentName;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 饰品名称Mapper接口
 *
 * @author ruoyi
 * @date 2025-10-04
 */
@Repository
public interface CsOrnamentNameMapper extends BaseMapper<CsOrnamentName> {
    /**
     * 查询饰品名称
     *
     * @param id 饰品名称主键
     * @return 饰品名称
     */
    public CsOrnamentName selectCsOrnamentNameById(String id);

    /**
     * 查询饰品名称列表
     *
     * @param csOrnamentName 饰品名称
     * @return 饰品名称集合
     */
    public List<CsOrnamentName> selectCsOrnamentNameList(CsOrnamentName csOrnamentName);

    /**
     * 新增饰品名称
     *
     * @param csOrnamentName 饰品名称
     * @return 结果
     */
    public int insertCsOrnamentName(CsOrnamentName csOrnamentName);

    /**
     * 修改饰品名称
     *
     * @param csOrnamentName 饰品名称
     * @return 结果
     */
    public int updateCsOrnamentName(CsOrnamentName csOrnamentName);

    /**
     * 删除饰品名称
     *
     * @param id 饰品名称主键
     * @return 结果
     */
    public int deleteCsOrnamentNameById(String id);

    /**
     * 批量删除饰品名称
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteCsOrnamentNameByIds(String[] ids);



    @Insert("<script>" +
            "INSERT INTO cs_ornament_name (id, name, market_hash_name, platform_list, cs_qaq_id, " +
            " yyyp_item_id, c5_item_id, buff_item_id) VALUES " +
            "<foreach collection='list' item='item' separator=','>" +
            "(#{item.id}, #{item.name}, #{item.marketHashName}, #{item.platformList},#{item.csQaqId}, " +
            " #{item.yyypItemId}, #{item.c5ItemId}, #{item.buffItemId} )" +
            "</foreach>" +
            "ON DUPLICATE KEY UPDATE " +
            "market_hash_name = VALUES(market_hash_name), " +
            "platform_list = VALUES(platform_list)," +
            "cs_qaq_id = VALUES(cs_qaq_id)," +
            "yyyp_item_id = VALUES(yyyp_item_id)," +
            "c5_item_id = VALUES(c5_item_id)," +
            "buff_item_id = VALUES(buff_item_id)" +
            "</script>")
    void batchUpset(List<CsOrnamentName> records);

    @Update("<script>" +
            "<foreach collection='list' item='item' separator=';'>" +
            "UPDATE cs_ornament_name " +
            "SET steam_price = #{item.steamPrice}, steam_balance_price = #{item.steamBalancePrice}, " +
            " yyyp_price = #{item.yyypPrice}, steam_balance_discount_by_yyyp = #{item.steamBalanceDiscountByYyyp}, " +
            " buff_price = #{item.buffPrice}, steam_balance_discount_by_buff = #{item.steamBalanceDiscountByBuff}," +
            " c5_price = #{item.c5Price}, steam_balance_discount_by_c5 = #{item.steamBalanceDiscountByC5}," +
            " update_date = #{item.updateDate} " +
            "WHERE market_hash_name = #{item.marketHashName}" +
            "</foreach>" +
            "</script>")
    int batchUpdatePlatformPrice(List<CsOrnamentName> csOrnamentNames);

}
